<?php
require_once("XML/Unserializer.php");

/**
 * @author localuser
 * @version 1.0
 * @created 25-6-2008 12:44:13
 */
class ResourceConnector
{

	private $adapter;
 	private static $dataFile = "MLCOMResource.xml";
	public function __construct()
	{
		//$this->adapter =& new ResourceAdapter();
		$this->setResourceData();
	}

	/**
	 * 
	 * @param resourceCd
	 */
	public function getResourceValue($resourceCd)
	{
		/*
		$params[ResourceAdapter::$RESOURCEID] =& new Parameter(ResourceAdapter::$RESOURCEID,
											Parameter::$STRING_TYPE,
											$resourceCd);
		$params[ResourceAdapter::$CULTURE] =& new Parameter(ResourceAdapter::$CULTURE,
											Parameter::$STRING_TYPE,
											CommonConfig::getCulture());									
		$this->adapter->setSelectString($this->params);
		$result = $this->adapter->select($this->params);
		return $result[0][ResourceAdapter::$RESOURCEVALUE];
		*/
		return $this->resourceTable[$resourceCd];
		
	}

	private $resourceTable;
	private function setResourceData()
	{
		 $buffer = "";
		 $fp = fopen(ResourceConnector::$dataFile, "r");
		 while(!feof($fp))
		 {
		 	$buffer .= fgets($fp);
		 }
			fclose($fp);
		
		$unser =& new XML_Unserializer();
		$unser->unserialize($buffer);
		$this->resourceTable = null;
		foreach($unser->getUnserializedData() as $resources)
		{
			
			foreach($resources as $resource)
			{
				$this->resourceTable[$resource["resourceid"]] = $resource["resourcevalue"];
			}
		}
	}
	
}
?>